import request from "@/utils/request";

// 获取商品列表
export function getProductList(params) {
	return request.get("/products/list", params);
}

// 获取商品详情
export function getProductDetail(id) {
	return request.get(`/products/findOne/${id}`);
}

// 新增商品
export function addProduct(data) {
	return request.post("/products/create", data);
}

// 更新商品
export function updateProduct(id, data) {
	return request.patch(`/products/update/${id}`, data);
}

// 删除商品
export function deleteProduct(id) {
	return request.delete(`/products/delete/${id}`);
}

// 更新商品状态
export function updateProductStatus(id, status) {
	return request.patch(`/products/update/${id}`, { status });
}

// 获取商品规格列表
export function getProductSpecs(productId) {
	return request.get(`/products/${productId}/specs`);
}

// 添加商品规格
export function addProductSpec(productId, data) {
	return request.post(`/products/${productId}/specs`, data);
}

// 删除商品规格
export function deleteProductSpec(specId) {
	return request.delete(`/products/specs/${specId}`);
}

// 获取商品SKU列表
export function getProductSkus(productId) {
	return request.get(`/products/${productId}/skus`);
}

// 添加商品SKU
export function addProductSku(productId, data) {
	return request.post(`/products/${productId}/skus`, data);
}

// 获取SKU详情
export function getSkuDetail(skuId) {
	return request.get(`/products/skus/${skuId}`);
}

// 删除商品SKU
export function deleteProductSku(skuId) {
	return request.delete(`/products/skus/${skuId}`);
}

// 更新商品SKU
export function updateProductSku(skuId, data) {
	return request.patch(`/products/skus/${skuId}`, data);
}
